HttpClient (Script v2)

The following commands can be used to transfer data over a secure HTTP connection.

HttpClient.Upload( table )

HttpClient.Download( table )

'table' has the following entries

HttpClient Table Entries

Name

Type

Description

Url

string

The URL to either upload to or download from

Headers

table

a table of header ( string --> string )

User

string

Username for authenticated sites

Password

string

Password for authenticated sites

Data

string

Used by .Upload

Method

string

Either "POST" or "PUT", used by .Upload

EventHandler

function

Function to call with status. Signature is function( table, http_code, data, error ). 'code' is the http return code (200 is good).

 

Example 1: Get a web page and show the return code, the page source and any errors in the debug window.

function done(tbl, code, d, e)

print( code, d, e )

end

 

HttpClient.Download { Url = "http://www.google.com", EventHandler = done }

Example 1: Send Post data to a web site (Henry's HTTP Post Dumping Server). Note that this example uses the same EventHandler function as Example 1

function done(tbl, code, d, e)

print( code, d, e )

end

 

HttpClient.Upload {

Url = "http://posttestserver.com/post.php",

Method = "POST",

User = "Admin",

Password = "test",

Data = "this is a test",

Headers = {

["Content-Type"] = "text/html",

Larry = "another larry"

},

EventHandler = done

}


 

© 2009 - 2016 QSC, LLC. All rights reserved. QSC and the QSC logo are trademarks of QSC, LLC in the U.S. Patent and Trademark office and other countries. All other trademarks are the property of their respective owners.

http://patents.qsc.com.